package main

import (
	"fmt"
)

//MyInt looks like just a redefinetion of int, but they are different types.
type MyInt int

func (i MyInt) show1() int {
	//in declaration i is MyInt, so in the method i is assigned to the value of calling variable
	fmt.Println(i)
	// return i     //though MyInt is an alias of int, they are different types. so return i which is of type MyInt, rather than desired int, is NOT allowed here
	return 1
}

func (pi *MyInt) show2() {
	//in declaration pi is the pointer of MyInt, so in the method pi is assigned to the pointer of the calling variable
	fmt.Println(pi)
	// return *pi  //function must define return type if it returns value, otherwise compiler error appears
}

func main() {
	var v1 MyInt = 1

	r1 := v1.show1()
	fmt.Println(r1)
	//unlike javascript and python that function with no return value actually returns null or None. in Go funciton with no return value truely returns nothing, so that it can't be used to assigment, the next line cause compiler error
	// r2 := v1.show2()
	v1.show2()

	// methods defined for MyInt can't be used on int. following lines cause compiler error
	// var v2 int = 2
	// v2.show()
}
